<?php
/**
 * Created by PhpStorm.
 * User: hehecat
 * Date: 2018/8/30
 * Time: 12:08
 */

namespace app\admin\controller;


use app\admin\model\ClubModel;
use think\Controller;

class Club extends Controller {
    public function club() {
        $adminid = 1;

        $model = new ClubModel();
        $result = $model->getClub($adminid);
        $this->assign("list",$result);
        return $this->fetch();
    }

    public function editClub() {
        $clubid = input("clubid");
        $clubname = input("clubname");
        $intro = input("intro");

        $clubimg = request()->file('clubimg');

        $model = new ClubModel();
        // 移动到框架应用根目录/public/uploads/ 目录下
        if($clubimg){
            $info = $clubimg->move(ROOT_PATH . 'public' . DS . 'uploads');
            if($info){
                $result = $model->editVideo($clubid,$clubname,$info->getSaveName(),$intro);
                if ($result){
                    $this->success("修改成功");
                }
            }else{
                // 上传失败获取错误信息
                echo $clubimg->getError();
            }
        }else {
            $result = $model->editVideo2($clubid,$clubname,$intro);
            if ($result){
                $this->success("修改成功");
            }
        }
    }
}